package com.zmh.license.info;

import cn.hutool.system.oshi.OshiUtil;
import lombok.extern.slf4j.Slf4j;
import oshi.hardware.ComputerSystem;

import java.net.InetAddress;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author summer
 * @date 2023-03-13 11:08
 */
@Slf4j
public class MacServer extends LicenseAbstractServer {

    @Override
    protected List<String> getIpAddress() {
        List<InetAddress> localAllInetAddress = getLocalAllInetAddress();
        return localAllInetAddress.stream().map(InetAddress::getHostAddress).distinct().map(String::toLowerCase).collect(Collectors.toList());
    }

    @Override
    protected List<String> getMacAddress() {
        List<InetAddress> localAllInetAddress = getLocalAllInetAddress();
        return localAllInetAddress.stream().map(this::getMacByInetAddress).distinct().collect(Collectors.toList());
    }

    @Override
    protected String getCpuInfo() {
        ComputerSystem system = OshiUtil.getSystem();
        return system.getHardwareUUID();
    }

    @Override
    protected String getMainBoardSerial() {
        ComputerSystem system = OshiUtil.getSystem();
        return system.getBaseboard().getSerialNumber();
    }
}
